package jk.spider.util.cheat;

import jk.spider.core.SpiderController;
import jk.spider.util.SpiderUtil;
import jk.spider.util.cheat.impl.CookieCheat;
import jk.spider.util.cheat.impl.ExitCheat;
import jk.spider.util.cheat.impl.NullCheat;
import jk.spider.util.config.PropertySet;

public class SpiderCheatFactory {
	public SpiderCheat createCheat(SpiderController controller, PropertySet props) {
		SpiderCheat cheat = null;
		String strCheat = props.getString("cheat", "NullCheat");
		if(!SpiderUtil.isStringNull(strCheat) && strCheat.trim().equalsIgnoreCase("cookie")) {
			cheat = new CookieCheat(controller);
		} else if (!SpiderUtil.isStringNull(strCheat) && strCheat.trim().equalsIgnoreCase("exit")) {
			cheat = new ExitCheat(controller);
		} else {
			cheat = new NullCheat(controller);
		}
		return cheat;
	}
}
